/*problem describe: tu 
 * programmer     : TangQiao
 *
 *
 *
 */


#include "stdio.h"

int doit(int tu[6][6],int n,int k,int ss[18])
{
	int a, x, y, e,f;
	x=(k+n-1)/n;
	y=k-n*(x-1); 
	if (tu[x][y]==1) return(0);
	a=k; e=x; f=y;
	while (a>n) 
	{
		if (tu[e-1][f]==1) break;
		if (ss[a-n]==1)	return(0);
		--e;
		a-=n;
	}
	a=k; e=x; f=y;
	while ( a< (n*(n-1)+1) )
	{	
		if (tu[e+1][f]==1) break;
		if (ss[a+n]==1) return(0);
		++e;
		a+=n;
	}
	a=k; e=x; f=y;
	while ( ( (a-1)%n )>0 )
	{
		if (tu[e][f-1]==1) break;
		if (ss[a-1]==1)	return(0);
		--f;
		--a;
	}
	a=k; e=x; f=y;
	while ( (a%n)>0 )
	{
		if (tu[e][f+1]==1) break;
		if (ss[a+1]==1) return(0);
		++f;
		++a;
	}
	return(1);	
}


main()
{
	int tu[6][6], ss[18], k ;
	int i,j,n,n2,sign;
	int tot;
	char s[6];
	int out[18];

	scanf("%d",&n);
	while (n!=0)
	{
		memset(tu,0,sizeof(tu));
		for (i=1;i<=n;++i) 
		{
			scanf("%s",s);
			for (j=0;j<n;++j) 
				if (s[j]=='X') tu[i][j+1]=1;
		}
		
		memset(ss,0,sizeof(ss));
		tot=0;
		n2=n*n;
		k=1;
		ss[k]=-1;
		while (k>=1)
		{
			++ss[k];
			if (k>n2) 
			{   	sign=1; j=0;      
				for (i=1;i<=n2;++i) 
				{	
					if (ss[i]==1) 
					{
						if (doit(tu,n,i,ss)==0)
						{       sign=0;
						        break;
						}
						++j;
					}
				}
				if ( (sign==1)&&(tot<j) ) 
				{
					tot=j;
				}
				--k;
			}
			else if (ss[k]>1)
			{
				--k;
			}
			else
			{
				++k;
				ss[k]=-1;
			}			
		}
		printf("%d\n",tot);

		scanf("%d",&n);
	}
}



